package com.qumitech.visualnovel.service.account;

import com.qumitech.visualnovel.datasource.console.SysUserRoleMapper;
import com.qumitech.visualnovel.model.dao.console.SysRole;
import com.qumitech.visualnovel.model.dao.console.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysUserRoleServiceImpl implements SysUserRoleService {
    @Autowired
    SysUserRoleMapper sysUserRoleMapper;

    @Override
    public void setUserSysRole(int uid, int role_id) {
        sysUserRoleMapper.unBindUserSysRole(uid);
        sysUserRoleMapper.bindUserSysRole(uid,role_id);
    }

    @Override
    public void unBindUserSysRole(int uid) {
        sysUserRoleMapper.unBindUserSysRole(uid);
    }

    @Override
    public List<UserInfo> getUsersByRoleId(int rid) {
        return sysUserRoleMapper.getUsersByRoleId(rid);
    }

    @Override
    public List<SysRole> getSysRoleByUid(int uid) {
        return sysUserRoleMapper.getRolesByUserId(uid);
    }


}
